<?php
session_start();
include("config/config.php");
$shab = $shab_dir."/index.php";
if(file_exists($shab)){$shab_p=file_get_contents($shab);} else {die("Шаблон не найден!");}
if(isset($_GET ['prof'])){ $prof = htmlspecialchars($_GET ['prof']); $pdir =$pdir.$prof;
if(!file_exists($pdir) or !file_exists($pdir."/config.php")){die("Такого пользователя не существует! <a href=\"/\">Главная</a>");}
include($pdir."/config.php");
include("blmsg.php");
$about = htmlspecialchars($about);
$site = htmlspecialchars($site);
$log_panel = file_get_contents($shab_dir."/login.php");
$panel = file_get_contents($shab_dir."/panel.php");
$fr_panel = file_get_contents($shab_dir."/fr_panel.php");
$add = file_get_contents($shab_dir."/add.php");
if($_SESSION['logmit']=='' or !isset($_SESSION['logmit'])){
	$shab_p = str_replace("%LOGIN%",$log_panel,$shab_p);
} else {
	$log = $_SESSION['logmit'];
	$put =  $pdir.$log."/config.php";
	if(file_exists($put)){include($put);} else {echo 'Ошибка. Перейдите <a href="login.php?to=exit">сюда</a>.'; exit;}
	if($site==''){
	$site = "Не имеется";}
	$send_panel = str_replace("%SITE%",$site,$panel);
	$send_panel = str_replace("%LOGIN%",$name,$send_panel);
	$send_panel = str_replace("%INV%",$invite,$send_panel);
	$shab_p = str_replace("%LOGIN%",$send_panel,$shab_p);
	$shab_p = str_replace("%FR%",$fr_panel,$shab_p);
	$shab_p = str_replace("%LOGIN%",$name,$shab_p);
	$namee = $name;
}
$put =  $pdir.$prof."/config.php";
include($put);
$site =  str_replace("http://",'',$site);
if($site!=''){
$site = '<a href="http://'.$site.'">'.substr($site,0,10)."...".'</a>';} else {$site = "Не имеется";}
$shab_p = str_replace("%TITLE%","$titm - ".$prof,$shab_p);
$shab_p = str_replace("%SHB%",$shab_dir,$shab_p);
$shab_p = str_replace("%ADR%","?prof=".$_SESSION['logmit'],$shab_p);
$shab_p = str_replace("%FR%",'',$shab_p);
$shab_p = str_replace("%LOGIN%",$namee,$shab_p);
$shab_p = str_replace("%BODY%","<tr id=\"hdr\"><td>$titm blog - $prof | $about | $site</td></tr>",$shab_p);
$shab_p = str_replace("%BLOGMSG%",$blog_ms_out,$shab_p);
if($_SESSION['logmit']==$_GET ['prof']){
$add = str_replace("%LOGIN%",$namee,$add);
$shab_p = str_replace("%ADD%",$add,$shab_p);} else {$shab_p = str_replace("%ADD%",'',$shab_p);}
if(@$_GET['do']!='arhive'){$shab_p = str_replace("%FOOTER%",'<div id="footer"><a href="/add" rel="/friend_add.php?fr='.$prof.'&do='.$namee.'" id="ADD">Добавить</a> '." | <a href=\"".$_SERVER['REQUEST_URI']."&do=arhive\">Все записи</a><br>".$footer.'<br />
<a href="/plugins/console"  id="err">Консоль ошибок</a></div>
',$shab_p);} else {$shab_p =  str_replace("%FOOTER%",$footer,$shab_p);}
echo $shab_p;
exit;}
$log_panel = file_get_contents($shab_dir."/login.php");
$panel = file_get_contents($shab_dir."/panel.php");
if($_SESSION['logmit']=='' or !isset($_SESSION['logmit'])){
	$shab_p = str_replace("%LOGIN%",$log_panel,$shab_p);
} else {
	$log = $_SESSION['logmit'];
	$put =  $pdir.$log."/config.php";
	if(file_exists($put)){include($put);} else {echo 'Ошибка. Перейдите <a href="login.php?to=exit">сюда</a>.'; exit;}
	$about = htmlspecialchars($about);
	$site = htmlspecialchars($site);
	$send_panel = str_replace("%SITE%",$site,$panel);
	$send_panel = str_replace("%LOGIN%",$name,$send_panel);
	$send_panel = str_replace("%INV%",$invite,$send_panel);
	$shab_p = str_replace("%LOGIN%",$send_panel,$shab_p);
}
$blogmsg = file_get_contents($shab_dir."/main.php");
$shab_p = str_replace("%SHB%",$shab_dir,$shab_p);
$shab_p = str_replace("%TITLE%",$pname,$shab_p);
$shab_p = str_replace("%FR%",'',$shab_p);
$shab_p = str_replace("%BODY%",'<tr id="hdr"><td>'.$pname.'::Добро пожаловать</td></tr>',$shab_p);
$shab_p = str_replace("%BLOGMSG%",'<tr><td id="tr">
'.$blogmsg.'
</td></tr>',$shab_p);
$shab_p = str_replace("%FOOTER%",$footer.'<br />
<a href="/plugins/console" id="err">Консоль ошибок</a>',$shab_p);
$shab_p = str_replace("%ADD%",'',$shab_p);
if($_SESSION['logmit']=='' or !isset($_SESSION['logmit'])){
	$shab_p = str_replace("%LOGIN%",$log_panel,$shab_p);
	$shab_p = str_replace("%ADR%",'',$shab_p);
} else { $shab_p = str_replace("%ADR%","?prof=".$_SESSION['logmit'],$shab_p);}
echo $shab_p;

?>